Dashboard.addWidget({ getId : function(){ return 'table-overview-detailed-widget'; }, getName : function(){ return 'Table Overview Detailed'; }, getDescription : function(){ return { en : 'Widget that display a detailed tabular overview of the current model and goals status', de : 'Widget that display a detailed tabular overview of the current model and goals status' }; }, getIconClass : function(){ return 'glyphicon glyphicon-th'; }, createContent : function(configuration, currentWidgetInstanceId){ var treeJson = (configuration.hyerarchicalView.value=='true')?ModelManager.buildModelTreeStructure():ModelManager.buildModelLinearStructure(); var _createCircleCode = function(color){ return''; } var _formatGoalStatusAsTrafficLightCode = function(status){ if(status == null) return _createCircleCode('lightgrey')+' '+_createCircleCode('lightgrey')+' '+_createCircleCode('lightgrey'); return _createCircleCode(status>0?'green ':'lightgrey')+' '+_createCircleCode(status==0?'grey ':'lightgrey')+' '+_createCircleCode(status<0?'red ':'lightgrey'); } var _formatKpiValue = function(value, measureUnit){ if(value == null) value = '--'; return '
' + value + ' ' + measureUnit + '
'; }; var tableNode = $(''); var ret = tableNode.append( $('').append(function(){ var toAppend = []; var _appendRowRec = function(node, levelNum){ var _getSpaces = function(){ var ret = ''; for(var i=0;i0 && measure.columns.length>0)?measure.data[0][measure.columns[0]]:null); }catch(e){ errorMsg = e; } objInfo = node.isAGoal?ModelManager.getGoalInfo(node.model_id, node.object_id):ModelManager.getKpiInfo(node.model_id, node.object_id); valueToDisplay = node.isAGoal ? _formatGoalStatusAsTrafficLightCode(lastValue) : _formatKpiValue(lastValue, (measure!=null && measure.columns.length>0)?objInfo.getFieldInfos(measure.columns[0]).measureUnit:''); } toAppend.push($('') .attr('data-levelId', node.levelId) .attr('data-visibleChilds', 'true') .attr('data-model_id', node.model_id) .attr('data-isAGoal', node.isAGoal) .attr('data-object_id', node.object_id) .attr('data-lastValue', lastValue) .append( $('') .click(function(){ if(node.nodes == null || node.nodes.length == 0) return; if($(this.parentNode).attr('data-visibleChilds') == 'true'){ ret.find('tr[data-levelId ^= "'+node.levelId+'-"]').hide(); $(this).parent().attr('data-visibleChilds', 'false'); } else { ret.find('tr[data-levelId ^= "'+node.levelId+'-"]').show(); $(this).parent().attr('data-visibleChilds', 'true'); var firstSpan = ret.find('tr[data-levelId ^= "'+node.levelId+'-"]').find('span').first(); if(firstSpan.hasClass('glyphicon-chevron-right')){ firstSpan.removeClass('glyphicon-chevron-right'); firstSpan.addClass('glyphicon-chevron-down'); } } $(this).find('span').first().toggleClass('glyphicon-chevron-right'); $(this).find('span').first().toggleClass('glyphicon-chevron-down'); }) ).append( $('').popover({ placement : 'auto right', container : 'body', html : true, title : node.text + ' details', content : function(){ var html = '

'+node.description+'

'; if(objInfo == null) return html; if(errorMsg != null){ html += '

Error Occurred: '+errorMsg+'

'; return html; } if(measure==null) throw 'Unexpected Exception!'; if(node.isAGoal){ html += '
'+valueToDisplay+'
'; html += ''; html += ''; if(objInfo.type!=null) html += ''; for(var moreInfoKey in measure.moreInfo) html += ''; html += '
DetailsValues
status'+(measure.status==0?'UNKNOWN':(measure.status>0?'SUCCESS':'FAILURE'))+'
type'+objInfo.type+'
'+moreInfoKey+''+measure.moreInfo[moreInfoKey]+'
'; } else { html += ''; html += ''; measure.columns.forEach(function(item){ html += ''; }); html += ''; measure.data.forEach(function(dataItem, index){ if(index > 10) return; html += ''; measure.columns.forEach(function(columnName){ html += ''; }); html += ''; }); if(measure.data.length > 10){ html += ''; measure.columns.forEach(function(item, i){ html += ''; }); html += ''; } if(measure.data.length == 0){ html += 'No information available'; } html += '
'+item+'
' + (dataItem[columnName]!=null?dataItem[columnName] + ' ' + objInfo.getFieldInfos(columnName).measureUnit :'') + '
'+(i==0?'...':'')+'
'; html += '

More informations:

'; html += ''; for(var moreInfoKey in measure.moreInfo) html += ''; if(Object.keys(measure.moreInfo).length==0 && objInfo.type==null && Object.keys(objInfo.moreInfo).length==0) html += ''; if(objInfo.type!=null) html += ''; for(var moreInfoKey in objInfo.moreInfo) html += ''; html += '
'+moreInfoKey+''+measure.moreInfo[moreInfoKey]+'
No additional infos available
type'+objInfo.type+'
'+moreInfoKey+''+objInfo.moreInfo[moreInfoKey]+'
'; } return html; }(), trigger : 'hover' }) ).append( function(){ if(node.isAGoal || measure==null) return $(''); var targetRangeStatusDom = null; if(measure.targetRangeAlgorithmResult!=null){ var targetRangeStatus = measure.targetRangeAlgorithmResult.status; var targetRangeStatusHtml = _createCircleCode(targetRangeStatus==null?'lightgrey':(targetRangeStatus>0?'green':(targetRangeStatus<0?'red':'grey'))); targetRangeStatusDom = $('
').append($(targetRangeStatusHtml)).popover({ placement : 'auto left', container : 'body', html : true, title : node.text + ' target range status additional infos', content : function(){ var html = ''; for(var moreInfoKey in measure.targetRangeAlgorithmResult.moreInfo) html += ''; if(Object.keys(measure.targetRangeAlgorithmResult.moreInfo).length==0) html += ''; html += '
'+moreInfoKey+''+measure.targetRangeAlgorithmResult.moreInfo[moreInfoKey]+'
No additional infos available
'; return html; }(), trigger : 'hover' }); } var alertRangeStatusDomList = []; for(var i=0;i').append($(alertCurrentStatusHtml)).popover({ placement : 'auto left', container : 'body', html : true, title : node.text + ' alert range status additional infos', content : function(){ var html = ''; for(var moreInfoKey in alertCurrentResult.moreInfo) html += ''; if(Object.keys(alertCurrentResult.moreInfo).length==0) html += ''; html += '
'+moreInfoKey+''+alertCurrentResult.moreInfo[moreInfoKey]+'
No additional infos available
'; return html; }(), trigger : 'hover' }); alertRangeStatusDomList.push(alertCurrentStatusDom); } return $('').append( targetRangeStatusDom ).append( alertRangeStatusDomList ); }() )); if(node.nodes!=null) node.nodes.forEach(function(item){ _appendRowRec(item, levelNum+1); }); }; _appendRowRec(treeJson, 0); return toAppend; }()) ); Dashboard.events.onFilterBySelectionClick(function(e){ var levelId = null; ret.find('tr').each(function(index, trDom){ var tr = $(trDom); if(tr.attr('data-model_id') == e.modelId && tr.attr('data-isAGoal') == (e.isGoal!=null?''+e.isGoal:null) && tr.attr('data-object_id') == e.objectId) levelId = tr.attr('data-levelId'); }); if(levelId == null) throw 'Unexpected Error: Impossible to find the levelId'; ret.find('tr:not([data-levelId ^= "'+levelId+'"])').hide(); ret.find('tr').each(function(index, trDom){ var tr = $(trDom); if(levelId.startsWith(tr.attr('data-levelId'))) tr.show(); }); ret.find('tr[data-levelId ^= "'+levelId+'"]').show(); }); Dashboard.events.onFilterByValuesChange(function(e){ var showSuccessGoal = e.showSuccessGoal; var showFailureGoal = e.showFailureGoal; var showUnknownGoal = e.showUnknownGoal; var minKpiVal = e.minKpiVal; var sameKpiVal = e.sameKpiVal; var maxKpiVal = e.maxKpiVal; ret.find('tr').each(function(index, trDom){ var tr = $(trDom); if(tr.attr('data-model_id')==null || tr.attr('data-isAGoal')==null || tr.attr('data-object_id')==null) tr.show(); else { if(tr.attr('data-isAGoal')=='true'){ tr.hide(); if(showSuccessGoal && tr.attr('data-lastValue') > 0) tr.show(); if(showFailureGoal && tr.attr('data-lastValue') < 0) tr.show(); if(showUnknownGoal && tr.attr('data-lastValue') == 0) tr.show(); } else { tr.show(); if(minKpiVal != '' && !(tr.attr('data-lastValue') > minKpiVal)) tr.hide(); if(sameKpiVal != '' && !(tr.attr('data-lastValue') == sameKpiVal)) tr.hide(); if(maxKpiVal != '' && !(tr.attr('data-lastValue') < maxKpiVal)) tr.hide(); } } }); }); return ret; }, getConfiguration : function(){ return { hyerarchicalView : { description : { en : '', de : '' }, value : '' } }; }, createConfiguration : function(presetConfig){ var node = $('
Hyerarchical Model View
'); if(presetConfig != null) if(presetConfig.hyerarchicalView!=null) node.find('#selectionTypeChk').prop('checked', (presetConfig.hyerarchicalView.value=='true')); var okHandler = function(){ var hyerarchicalView = node.find('#selectionTypeChk').is(':checked'); return { hyerarchicalView : {value : ''+hyerarchicalView} } }; return { nodeElement : node, okHandler : okHandler }; }, getPreferredSize : function(){ return {w:10, h:10}; } });